package 强化训练;

public class day27不用加减求和 {
    public int Add(int num1,int num2) {
        //将num1与num2进行&运算之后左移一位，赋给num1，如果num1==0，返回num2
        //num2 每次等于num1与num2的^；
        while(num1 != 0){
            int sum = (num1 & num2) << 1;
            num2 = num1 ^ num2;
            num1 = sum;
        }
        return num2;
    }
}
